function perOrder(param, ordNo) {
    tradePay(param, ordNo);
}

function ready(callback) {
    if (window.AlipayJSBridge) {
        callback && callback();
    } else {
        document.addEventListener('AlipayJSBridgeReady', callback, false);
    }
}

function tradePay(jsapiJson, ordNo) {
    ready(function(){
        // 通过传入交易号唤起快捷调用方式(注意tradeNO大小写严格)
        console.info("开始拉起支付宝支付:", jsapiJson)
        var jsapi = eval('(' + jsapiJson + ')');
        AlipayJSBridge.call("tradePay",jsapi, function (data) {
            var result = "";
            var errMsg = "";
            if ("9000" == data.resultCode) {
                result = "success";
            }else{
                if ("8000" == data.resultCode) {
                    errMsg = "用户支付中";
                } else if ("4000" == data.resultCode)
                {
                    errMsg = "支付失败";
                } else if ("6001" == data.resultCode) {
                    errMsg = "用户取消支付";
                } else if ("6002" == data.resultCode) {
                    errMsg = "网络连接出错";
                } else {
                    errMsg = "其他原因导致失败";
                }
                result = "error";
            }
            console.info("当前请求响应:",data)
            location.href = root + "pay/notice?ordNo=" + ordNo + "&result=" + result + "&errMsg=" + errMsg;
        });
    });
}

function close() {
    ready(function () {
        AlipayJSBridge.call("closeWebview");
    })
}